//
//  DZDModel.swift
//
//  Created by 邱仙凯 on 2021/9/27
//  Copyright (c) . All rights reserved.
//

import Foundation
import ObjectMapper

public struct ZyaDZDModel: Mappable {

  // MARK: Declaration for string constants to be used to decode and also serialize.
  private struct SerializationKeys {
    static let pMonth = "p_month"
    static let homePageDetail = "homePageDetail"
    static let monthDfMoney = "month_df_money"
    static let monthYfMoney = "month_yf_money"
    static let monthSockMoney = "month_sock_money"
  }

  // MARK: Properties
  public var pMonth: String?
  public var homePageDetail: [ZyaHomePageDetail]?
  public var monthDfMoney: Double?
  public var monthYfMoney: Double?
  public var monthSockMoney: Double?

  // MARK: ObjectMapper Initializers
  /// Map a JSON object to this class using ObjectMapper.
  ///
  /// - parameter map: A mapping from ObjectMapper.
  public init?(map: Map){

  }

  /// Map a JSON object to this class using ObjectMapper.
  ///
  /// - parameter map: A mapping from ObjectMapper.
  public mutating func mapping(map: Map) {
    pMonth <- map[SerializationKeys.pMonth]
    homePageDetail <- map[SerializationKeys.homePageDetail]
    monthDfMoney <- map[SerializationKeys.monthDfMoney]
    monthYfMoney <- map[SerializationKeys.monthYfMoney]
    monthSockMoney <- map[SerializationKeys.monthSockMoney]
  }

  /// Generates description of the object in the form of a NSDictionary.
  ///
  /// - returns: A Key value pair containing all valid values in the object.
  public func dictionaryRepresentation() -> [String: Any] {
    var dictionary: [String: Any] = [:]
    if let value = pMonth { dictionary[SerializationKeys.pMonth] = value }
    if let value = homePageDetail { dictionary[SerializationKeys.homePageDetail] = value.map { $0.dictionaryRepresentation() } }
    if let value = monthDfMoney { dictionary[SerializationKeys.monthDfMoney] = value }
    if let value = monthYfMoney { dictionary[SerializationKeys.monthYfMoney] = value }
    if let value = monthSockMoney { dictionary[SerializationKeys.monthSockMoney] = value }
    return dictionary
  }

}
